//
//  CJAuthenticationController.m
//  Boss
//
//  Created by admin on 2018/9/13.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "CJAuthenticationController.h"
#import "CJIdentityAuthenticationController.h"
#import "CJOccputionAuthenticationController.h"
#import "CJAuthenticationStatus.h"
#import "CJSuccessAuthenticationController.h"
#import "CJErrorAuthenticationController.h"
@interface CJAuthenticationController ()
@property (strong, nonatomic) IBOutlet UIView *mainView;
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@property (nonatomic,strong) CJAuthenticationStatus *status;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *topHeight;
@property (strong, nonatomic) IBOutlet UILabel *firmStatusLabel;

@property (strong, nonatomic) IBOutlet UILabel *userStatusLabel;



@end

@implementation CJAuthenticationController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    self.topHeight.constant = self.navHeight;
    
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self loadAuthenticationStatus];
    
}

-(void)loadAuthenticationStatus
{
    WEAKSELF
    [WYHttpServer getAuthenticationStatusSucessBlock:^(BOOL success, id response, NSString *errorMessage) {
       
        if (success) {
            weakSelf.status = [CJAuthenticationStatus getAuthenticationStatusModelFromJson:response[@"result"]];
            [weakSelf upDateUI];
        }
        
        
    }];
    
    
    
}
-(void)upDateUI
{
    if (self.status.firmCertificationStatus.intValue==0) {
        self.firmStatusLabel.text = @"认证中...";
    }else if(self.status.firmCertificationStatus.intValue==1){
        self.firmStatusLabel.text = @"已认证";
    }else if(self.status.firmCertificationStatus.intValue==2){
        self.firmStatusLabel.text = @"认证失败";
    }else if(self.status.firmCertificationStatus.intValue==3){
        self.firmStatusLabel.text = @"未认证";
    }else if(self.status.firmCertificationStatus.intValue==4){
       self.firmStatusLabel.text = @"认证成功";
    }
    if (self.status.userCertificationStatus.intValue==0) {
        self.userStatusLabel.text = @"认证中...";
    }else if(self.status.userCertificationStatus.intValue==1){
        self.userStatusLabel.text = @"已认证";
    }else if(self.status.userCertificationStatus.intValue==2){
        self.userStatusLabel.text = @"认证失败";
    }else if(self.status.userCertificationStatus.intValue==3){
        self.userStatusLabel.text = @"未认证";
    }else if(self.status.userCertificationStatus.intValue==4){
        self.userStatusLabel.text = @"认证成功";
    }
    
    
    
    
}

-(void)setupUI
{
    self.mainView.width = kScreenWidth;
    self.mainView.height = kScreenHeight;
    [self.scrollView addSubview:self.mainView];
    self.scrollView.contentSize = self.mainView.size;
    
    self.navigationItem.title = @"加V认证";
    
  
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)occputionAction:(id)sender {
    
    if (self.status.firmCertificationStatus.intValue==3||self.status.firmCertificationStatus.intValue==1) {
        CJOccputionAuthenticationController *opc = [[CJOccputionAuthenticationController alloc]init];
        [self.navigationController pushViewController:opc animated:YES];
    }
    if (self.status.firmCertificationStatus.intValue == 2) {
        CJErrorAuthenticationController *evc = [[CJErrorAuthenticationController alloc]init];
        evc.tag = 2;
        [self.navigationController pushViewController:evc animated:YES];
        
    }
    if (self.status.firmCertificationStatus.intValue == 4) {
        CJSuccessAuthenticationController *sac = [[CJSuccessAuthenticationController alloc]init];
        [self.navigationController pushViewController:sac animated:YES];
        
    }
    
    
    
    
}

- (IBAction)identityAction:(id)sender {
    
    if (self.status.userCertificationStatus.intValue==3||self.status.userCertificationStatus.intValue==1) {
        CJIdentityAuthenticationController *iac = [[CJIdentityAuthenticationController alloc]init];
        [self.navigationController pushViewController:iac animated:YES];
    }
    if (self.status.userCertificationStatus.intValue == 2) {
        CJErrorAuthenticationController *evc = [[CJErrorAuthenticationController alloc]init];
        evc.tag = 1;
        [self.navigationController pushViewController:evc animated:YES];
        
    }
   
    
    
}


@end
